import React, { useState, useEffect } from "react";
import { Modal, Form, Row, Space, Button, Input, Select, message, Radio, RadioChangeEvent } from "antd";
import { twCardExamine } from './service';
import "./index.less";
const ForumInfo = (props) => {
  const { isOpen, onClose, updateData, getList } = props;
  const [form] = Form.useForm();

  useEffect(() => {
    form.setFieldsValue({
    ...updateData
  })
  }, [isOpen])

  const onCloseModal = () => {
    form.resetFields()
    onClose()
  }

  const onSubmit = async () => {
    const values = await form.validateFields()
    const res = await twCardExamine({
      id: updateData.id,
      type: updateData.type,
      ...values
    })
    if (res) {
      message.success('操作成功')
      onClose()
      getList()
    }
  }
  const onChangeType = ({ target: { value } }: RadioChangeEvent) => {
    form.setFieldValue('status', value)
  };
  return (
    <Modal
      width={600}
      title="用户个人资料"
      open={isOpen}
      onOk={onSubmit}
      onCancel={onCloseModal}
    >
      <Form form={form}>
        <Form.Item name="name" label="类型名称" rules={[
          {
            required: true,
            message: '必填',
          },
        ]}>
          <Input placeholder="请输入" />
        </Form.Item>
        <Form.Item name="status" label="审核状态" rules={[
          {
            required: true,
            message: '必填',
          },
        ]}>
          <Radio.Group
            onChange={onChangeType}
            options={[
              { value: '0', label: '显示' },
              { value: '1', label: '隐藏' }
            ]}
          />
        </Form.Item>
        
      </Form>
    </Modal>
  );
};
export default ForumInfo;
